﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace _1207_unique_number_of_occurrences
{
    class Program
    {
        static void Main (string[] args)
        {
            int[] arr = new int[] { 1, 2, 2, 1, 1, 3, 3, 3 };
            Console.WriteLine (new Solution().UniqueOccurrences(arr));
        }
    }

    public class Solution
    {
        public bool UniqueOccurrences (int[] arr)
        {
            Dictionary<int, int> num = new Dictionary<int, int> ();

            for (int i = 0;i < arr.Length;i++)
            {
                if (!num.ContainsKey (arr[i])) num.Add (arr[i], 0);
                num[arr[i]]++;
            }

            foreach (var item in num)
            {
                if (num.Where (t => t.Value == item.Value).ToList ().Count > 1) return false;
            }

            return true;
        }
    }
}
